package org.qengine.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.qengine.entity.DataDictEntity;
import org.qengine.service.DataDictService;
import org.qengine.vo.DataDictVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("dataDict/")
public class DataDictController {
    @Autowired
    private DataDictService dataDictService;

    @PostMapping("/add")
    public String add(@RequestBody DataDictEntity dataDict) {
        Integer i =dataDictService.add(dataDict);
        if(i>0){
            return "success";
        }
        else {
            return "fail";
        }

    }

    @PostMapping("/delete/{id}")
    public String deleteById(@PathVariable Long id){
        Integer i =dataDictService.delete(id);
        if(i>0){
            return "success";
        }
        else {
            return "fail";
        }
    }
    @PostMapping("/update")
    public String update(@RequestBody DataDictEntity dataDict ){
        Integer i = dataDictService.update(dataDict);
        if(i>0){
            return "success";
        }
        else {
            return "fail";
        }
    }

    @PostMapping("/search")
        public IPage<DataDictEntity> search(@RequestBody DataDictVo dataDictVo){
            return dataDictService.search(dataDictVo);
        }



}
